<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>跑马灯</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <div id='app'>
        <button @click="start" :disabled="disabled">浪起来</button>
        <button @click="stop" :disabled="!disabled">低调</button>
        <h3>
            {{msg}}
        </h3>
    </div>


    <script>
        function dududu(){
            console.log('dududu');
        }

        const vm = new Vue({
            el: '#app',
            data: {
                msg: '猥琐发育,别浪~~！',
                intervalId:null,
                disabled:false
            },
            methods: {
                start() {
                    this.lalala()
                    this.disabled = true
                    this.intervalId = setInterval(() => {
                        var first = this.msg.substr(0,1)
                        var end = this.msg.substr(1)
                        this.msg = end + first
                    }, 500)
                },
                stop() {
                    dududu()
                    // 清除计数器，要知道清除哪一个计时器
                    clearInterval(this.intervalId)
                    this.disabled = false
                },
                lalala(){
                    console.log('lalala');
                },
                lalala:function(){

                }
            },
        })

        vm.lalala()
        console.log(vm);
    </script>
</body>

</html>